using System;
using System.Collections;
using System.Linq;
using System.Text.RegularExpressions;
using FluentAssertions;
using TailBlazer.Domain.Formatting;
using Xunit;

namespace TailBlazer.Fixtures;

public class SplitFileByMatchingRegexFixture
{
    public SplitFileByMatchingRegexFixture()
    {
    }

    [Fact]
    public void Test()
    {

        var input = "The lazy cat could not catch a mouse";
        var pattern = "lazy|mouse";
        var matches = Regex.Matches(input, pattern);
           
        Console.WriteLine(matches);

        //var matched = input.MatchString("Cats").ToArray();
        //var joined = matched.Select(m => m.Part).ToDelimited("");
        //joined.Should().Be(input);

        //var multimatched = input.MatchString("cat|lazy").ToArray();
        //var multijoined = multimatched.Select(m => m.Part).ToDelimited("");
        //multijoined.Should().Be(input);
    }


    [Fact]
    public void FindMatchingText()
    {

        var input = "The lazy cat could not catch a mouse";



        var matched = input.MatchString("Cats" ).ToArray();
        var joined = matched.Select(m => m.Part).ToDelimited("");
        joined.Should().Be(input);

        var multimatched = input.MatchString("cat|lazy").ToArray();
        var multijoined = multimatched.Select(m => m.Part).ToDelimited("");
        multijoined.Should().Be(input);
    }

    //[Fact]
    //public void FindWithNoMatch()
    //{
    //    var input = "The lazy cat could not catch a mouse";

    //    var matched = input.MatchString("energetic").ToArray();
    //    var joined = matched.Select(m => m.Part).ToDelimited("");
    //    joined.Should().Be(input);

    //    var multimatched = input.MatchString(new[] { "dog", "energetic" }).ToArray();
    //    var multijoined = multimatched.Select(m => m.Part).ToDelimited("");
    //    multijoined.Should().Be(input);
    //}

    //[Fact]
    //public void MatchAtEnd()
    //{
    //    var input = "The lazy cat could not catch a mouse";

    //    var matched = input.MatchString("mouse").ToArray();
    //    var joined = matched.Select(m => m.Part).ToDelimited("");
    //    joined.Should().Be(input);


    //    var multimatched = input.MatchString(new[] { "mouse" }).ToArray();
    //    var multijoined = multimatched.Select(m => m.Part).ToDelimited("");
    //    multijoined.Should().Be(input);
    //}

    //[Fact]
    //public void MatchAtStart()
    //{
    //    var input = "The lazy cat could not catch a mouse";

    //    var matched = input.MatchString("The").ToArray();
    //    var joined = matched.Select(m => m.Part).ToDelimited("");
    //    joined.Should().Be(input);

    //    var multimatched = input.MatchString(new[] { "The", "not" }).ToArray();
    //    var multijoined = multimatched.Select(m => m.Part).ToDelimited("");
    //    multijoined.Should().Be(input);
    //}

    //[Fact]
    //public void NoMatch()
    //{
    //    var input = "The lazy cat could not catch a mouse";
    //    var matched = input.MatchString("XXX").ToArray();
    //    var joined = matched.Select(m => m.Part).ToDelimited("");
    //    joined.Should().Be(input);

    //    var multimatched = input.MatchString(new[] { "XXX", "XXX" }).ToArray();
    //    var multijoined = multimatched.Select(m => m.Part).ToDelimited("");
    //    multijoined.Should().Be(input);
    //}

}